package cn.tedu.weibo2.service.impl;

import cn.tedu.weibo2.mapper.CommentMapper;
import cn.tedu.weibo2.pojo.dto.CommentDTO;
import cn.tedu.weibo2.pojo.entity.Comment;
import cn.tedu.weibo2.pojo.vo.CommentVO;
import cn.tedu.weibo2.service.CommentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public void inset(CommentDTO commentDTO) {
        Comment comment=new Comment();
        BeanUtils.copyProperties(commentDTO,comment);
        comment.setCreated(new Date());
        commentMapper.insert(comment);
    }

    @Override
    public List<CommentVO> list(Long weiboId) {
        return commentMapper.list(weiboId);
    }
}
